package com.xrit.sunnyday.job;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xrit.sunnyday.service.SetMealService;
import com.xrit.sunnyday.utils.QiNiuUtils;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 类名称: CleanImgJob
 * 类描述:TODO
 * 创建人: czb
 * 创建时间:2022/6/19 下午 01:07
 * Version 1.0.0
 */
@Component("cleanImgJob")
public class CleanImgJob {
    /*
     * 订阅服务*/
    @Reference
    private SetMealService setMealService;

    public void cleanImg() {
        //七牛云
        List<String> list = QiNiuUtils.listFile();
        //数据库
        List<String> imgInDb = setMealService.findImgs();
        list.removeAll(imgInDb);
        String[] strings = list.toArray(new String[]{});
        QiNiuUtils.removeFiles(strings);

    }
}
